<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<!--================================================================================
  Item Name: Materialize - Material Design Admin Template
  Version: 4.0
  Author: PIXINVENT
  Author URL: https://themeforest.net/user/pixinvent/portfolio
================================================================================ -->

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="msapplication-tap-highlight" content="no">
    <!--<meta name="description" content="Materialize is a Material Design Admin Template,It's modern, responsive and based on Material Design by Google. ">-->
    <!--<meta name="keywords" content="materialize, admin template, dashboard template, flat admin template, responsive admin template,">-->
    <title>BAUHINIA SQUARE Admin</title>
    <!-- Favicons-->
    <link rel="icon" href="images/favicon/favicon-32x32.png" sizes="32x32">
    <!-- Favicons-->
    <link rel="apple-touch-icon-precomposed" href="images/favicon/apple-touch-icon-152x152.png">
    <!-- For iPhone -->
    <meta name="msapplication-TileColor" content="#00bcd4">
    <meta name="msapplication-TileImage" content="images/favicon/mstile-144x144.png">
    <!-- For Windows Phone -->
    <!-- CORE CSS-->
    <link href="css//materialize.css" type="text/css" rel="stylesheet">
    <link href="css//style.css" type="text/css" rel="stylesheet">
    <!-- Custome CSS-->
    <link href="css/custom/custom.css" type="text/css" rel="stylesheet">
    <!-- INCLUDED PLUGIN CSS ON THIS PAGE -->
    <link href="vendors/perfect-scrollbar/perfect-scrollbar.css" type="text/css" rel="stylesheet">
    <link href="vendors/flag-icon/css/flag-icon.min.css" type="text/css" rel="stylesheet">

    <style>
        span.color-flag {
            border-radius:50%;
            height:1em;
            width:1em;
            display:inline-block;
            top:.2em;
            position:relative
        }
        span.text-flag {
            display:inline-block;
            font-size:.8em;
            margin-left:.5em;
            margin-right:1em;
        }
    </style>
</head>

<body ng-app="materializeApp" class="active-data-chart">
<!-- Start Page Loading -->
<div id="loader-wrapper">
    <div id="loader"></div>
    <div class="loader-section section-left"></div>
    <div class="loader-section section-right"></div>
</div>
<!-- End Page Loading -->
<!-- //////////////////////////////////////////////////////////////////////////// -->
<!-- START HEADER -->
<header id="header" class="page-topbar">
    <!-- start header nav-->
    <div class="navbar-fixed" th:include="header :: header"></div>
    <!-- end header nav-->
</header>
<!-- END HEADER -->
<!-- //////////////////////////////////////////////////////////////////////////// -->
<!-- START MAIN -->
<div id="main">
    <!-- START WRAPPER -->
    <div class="wrapper">
        <!-- START LEFT SIDEBAR NAV-->
        <aside id="left-sidebar-nav" th:include="leftNavigation :: navigation">
        </aside>
        <!-- END LEFT SIDEBAR NAV-->
        <!-- //////////////////////////////////////////////////////////////////////////// -->
        <!-- START CONTENT -->
        <section id="content">
            <!--breadcrumbs start-->
            <div id="breadcrumbs-wrapper">
                <div class="container">
                    <div class="row">
                        <div class="col s10 m6 l6">
                            <h5 class="breadcrumbs-title">会员列表</h5>
                            <ol class="breadcrumbs">
                                <li><a href="/">上海紫荆广场</a>
                                </li>
                                <li><a href="#">统计</a>
                                </li>
                                <li class="active">会员信息统计</li>
                            </ol>
                        </div>
                    </div>
                </div>
            </div>
            <!--breadcrumbs end-->
            <!-- //////////////////////////////////////////////////////////////////////////// -->
            <!--start container-->
            <div class="row">
                <div class="col s12 m12 l12">
                    <div id="chart-js-1" class="section">
                        <h4 class="header2">会员人数统计</h4>
                        <span class="text-flag"><input type="text" id="year" style="width: 100px;" placeholder="请输入年份"></span>
                        <button type="button" style="width: 60px;height: 25px;line-height: 25px;background: #b3ec5c;border: 0;border-radius: 6px;font-size: 12px;color: #333;" id="chosyear">确认</button>
                        <div class="row">
                            <div class="col s12">
                                <p>
                                </p>
                            </div>
                            <div class="col s12">
                                <div class="sample-chart-wrapper">
                                    <canvas id="member-chart-sample" height="120"></canvas>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div id="chart-js-2" class="section">
                        <h4 class="header2">活动数据统计</h4>
                        <div class="row">
                            <div class="col s12">
                                <p>
                                </p>
                            </div>
                            <div class="col s12">
                                <div class="sample-chart-wrapper">
                                    <canvas id="activity-chart-sample" height="120"></canvas>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div id="chart-js-3" class="section">
                        <h4 class="header2">优惠券数据统计</h4>
                        <div class="row">
                            <div class="col s12">
                                <p>
                                    <span class="color-flag" style="background-color:rgba(0, 191, 165,1)"></span>
                                    <span class="text-flag">领取数量</span>
                                    <span class="color-flag" style="background-color:rgba(255, 110, 64,1)"></span>
                                    <span class="text-flag">核销数量</span>
                                </p>
                            </div>
                            <div class="col s12">
                                <div class="sample-chart-wrapper">
                                    <canvas id="coupon-chart-sample" height="120"></canvas>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div id="chart-js-4" class="section">
                        <h4 class="header2">优惠券数据统计</h4>
                        <div class="row">
                            <div class="col s12">
                                <p>
                                </p>
                            </div>
                            <div class="col s12">
                                <div class="sample-chart-wrapper">
                                    <canvas id="assessment-chart-sample" height="120"></canvas>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--end container-->
        </section>
        <!-- END CONTENT -->
        <!-- START RIGHT SIDEBAR NAV-->
        <aside id="right-sidebar-nav" th:include="rightSidebarNav :: right-sidebar-nav">
        </aside>
        <!-- END RIGHT SIDEBAR NAV-->
    </div>
    <!-- END WRAPPER -->
</div>
<!-- END MAIN -->
<!-- //////////////////////////////////////////////////////////////////////////// -->
<!-- START FOOTER -->
<footer class="page-footer gradient-45deg-light-cyan-cyan" th:include="footer :: footer">
</footer>
<!-- END FOOTER -->
<!-- ================================================
Scripts
================================================ -->
<!-- jQuery Library -->
<script type="text/javascript" src="vendors/jquery-3.2.1.min.js"></script>
<!--angularjs-->
<script type="text/javascript" src="js/materialize.min.js"></script>
<!--scrollbar-->
<script type="text/javascript" src="vendors/perfect-scrollbar/perfect-scrollbar.min.js"></script>
<!--plugins.js - Some Specific JS codes for Plugin Settings-->
<script type="text/javascript" src="js/plugins.js"></script>
<!--custom-script.js - Add your own theme custom JS-->
<script type="text/javascript" src="js/custom-script.js"></script>

<!-- chartjs -->
<script type="text/javascript" src="vendors/chart.min.js"></script>


<script th:inline="javascript">
    var membersData = /*[[${membersData}]]*/ undefined
    if (membersData) membersData = membersData.split(',')

    var activityData = /*[[${activityData}]]*/ undefined
    if (activityData) activityData = activityData.split(',')

    var couponData = /*[[${couponData}]]*/ undefined
    if (couponData) couponData = couponData.split(',')

    var verfiData = /*[[${verfiData}]]*/ undefined
    if (verfiData) verfiData = verfiData.split(',')

    var assessmentData = /*[[${assessmentData}]]*/ undefined
    if (assessmentData) assessmentData = assessmentData.split(',')

    var MemberChartSampleData = {
        labels: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
        datasets: [{
            label: "member count dataset",
            fillColor: "rgba(0, 191, 165,0.2)",
            strokeColor: "rgba(0, 191, 165,1)",
            pointColor: "rgba(0, 191, 165,1)",
            pointStrokeColor: "#fff",
            pointHighlightFill: "#fff",
            pointHighlightStroke: "rgba(0, 191, 165,1)",
            data: membersData
        }]
    };

    var ActivityChartSampleData = {
        labels: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
        datasets: [{
            label: "activity count dataset",
            fillColor: "rgba(0, 191, 165,0.2)",
            strokeColor: "rgba(0, 191, 165,1)",
            pointColor: "rgba(0, 191, 165,1)",
            pointStrokeColor: "#fff",
            pointHighlightFill: "#fff",
            pointHighlightStroke: "rgba(0, 191, 165,1)",
            data: activityData
        }]
    }

    var CouponChartSampleData = {
        labels: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
        datasets: [{
            label: "coupon count dataset",
            fillColor: "rgba(0, 191, 165,0.2)",
            strokeColor: "rgba(0, 191, 165,1)",
            pointColor: "rgba(0, 191, 165,1)",
            pointStrokeColor: "#fff",
            pointHighlightFill: "#fff",
            pointHighlightStroke: "rgba(0, 191, 165,1)",
            data: couponData
        }, {
            label: "verification count dataset",
            fillColor: "rgba(255, 110, 64,0.2)",
            strokeColor: "rgba(255, 110, 64,1)",
            pointColor: "rgba(255, 110, 64,1)",
            pointStrokeColor: "#fff",
            pointHighlightFill: "#fff",
            pointHighlightStroke: "rgba(255, 110, 64,1)",
            data: verfiData
        }]
    }

    var AssessmentChartSampleData = {
        labels: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
        datasets: [{
            label: "member register dataset",
            fillColor: "rgba(0, 191, 165,0.2)",
            strokeColor: "rgba(0, 191, 165,1)",
            pointColor: "rgba(0, 191, 165,1)",
            pointStrokeColor: "#fff",
            pointHighlightFill: "#fff",
            pointHighlightStroke: "rgba(0, 191, 165,1)",
            data: assessmentData
        }]
    }


    $(document).ready(function () {
        if (membersData) {
            window.MemberChartSample = new Chart(document.getElementById("member-chart-sample").getContext("2d")).Line(MemberChartSampleData, {
                responsive: true
            })
        }

        if (activityData) {
            window.ActivityChartSample = new Chart(document.getElementById("activity-chart-sample").getContext("2d")).Line(ActivityChartSampleData, {
                responsive: true
            })
        }

        if (couponData && verfiData) {
            window.CouponChartSample = new Chart(document.getElementById("coupon-chart-sample").getContext("2d")).Line(CouponChartSampleData, {
                responsive: true
            })
        }

        if (assessmentData) {
            window.AssessmentChartSample = new Chart(document.getElementById("assessment-chart-sample").getContext("2d")).Line(AssessmentChartSampleData, {
                responsive: true
            })
        }
    })

    $('#chosyear').on('click',function() {
        $.ajax({
            type:"get",
            url:"/chartsnew",
            data:{
                year:$('#year').val()
            },
            success:function (res) {
                membersData = res.membersData;
                activityData =res.activityData;
                couponData = res.couponData;
                verfiData = res.verfiData;
                assessmentData = res.assessmentData;

                console.log(couponData);
                console.log(verfiData);
                console.log(assessmentData);

                //会员人数统计
                MemberChartSampleData.datasets[0].data=membersData.split(',');
                //销毁对象
                window.MemberChartSample.destroy();
                window.MemberChartSample = new Chart(document.getElementById("member-chart-sample").getContext("2d")).Line(MemberChartSampleData, {
                    responsive: true
                })

                //活动数据统计
                ActivityChartSampleData.datasets[0].data=activityData.split(',');
                //销毁对象
                window.ActivityChartSample.destroy();
                window.ActivityChartSample = new Chart(document.getElementById("activity-chart-sample").getContext("2d")).Line(ActivityChartSampleData, {
                    responsive: true
                })

                //优惠券数据统计
                CouponChartSampleData.datasets[0].data=couponData.split(",");
                CouponChartSampleData.datasets[1].data=verfiData.split(",");
                window.CouponChartSample.destroy();
                window.CouponChartSample = new Chart(document.getElementById("coupon-chart-sample").getContext("2d")).Line(CouponChartSampleData, {
                    responsive: true
                })

                //优惠券数据统计
                AssessmentChartSampleData.datasets[0].data = assessmentData.split(",");
                window.AssessmentChartSample.destroy();
                window.AssessmentChartSample = new Chart(document.getElementById("assessment-chart-sample").getContext("2d")).Line(AssessmentChartSampleData, {
                    responsive: true
                })

            },
            error:function (v) {
                console.log(v)
            }
        })
    })

</script>

</body>

</html>